<template>
  <div class="editSex">
    <van-nav-bar
      title="修改个人信息"
      right-text="保存"
      @click-right="baocun"
      left-arrow
      @click-left="$router.back()"
    />
    <van-radio-group v-model="store.res.sex">
      <van-cell-group inset>
        <van-cell title="男" clickable @click="store.res.sex = '0'">
          <template #right-icon>
            <van-radio name="0" />
          </template>
        </van-cell>
        <van-cell title="女" clickable @click="store.res.sex = '1'">
          <template #right-icon>
            <van-radio name="1" />
          </template>
        </van-cell>
      </van-cell-group>
    </van-radio-group>
  </div>
</template>

<script setup>
import { ref, reactive, toRefs } from "vue";
import { useCounterStore } from "@/stores/counter";
import { editUserNameApi } from "@/http/api";
import { useRouter } from "vue-router";
const router = useRouter();
const store = useCounterStore();

const baocun = async () => {
  const res = await editUserNameApi({ id: store.res.id, sex: store.res.sex });

  if (res.code == 200) {
    router.back();
  }
};
</script>
<style lang="scss" scoped></style>